package 每日一题;

public class 矩形面积 {
    //感悟： 编程和做数学题还是不一样的，编程具有普适性
    public int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
          int s=0;
          if (E>=C || G<=A || F>=D || H<=B)
              s=0;
          else {
              int x1 = Math.max(A,E);
              int x2 = Math.min(C,G);
              int y1 = Math.max(B,F);
              int y2 = Math.min(D,H);
              s = (x2-x1)*(y2-y1);
          }
          return (C-A)*(D-B)+(G-E)*(H-F)-s;
    }
}
